package com.billsystem.controller;
import com.billsystem.pojo.User;
import com.billsystem.service.UserService;
import com.billsystem.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
/*
在用户界面将个人信息的密码隐藏
 */

@RestController
public class IndexController {

    @Autowired
    private UserService userService;
    @Autowired
    private HttpSession session;

    @GetMapping("/welUser")
    public Object welUser(){
        int id = (int) session.getAttribute("userId");
        //通过用户id，获取到用户的全部信息
        User bean = userService.queryUserById(id);
        try {
            //将密码设置为空，防止被人审查到
            bean.setPassword("");
            return Result.success(bean);
        }catch (Exception e){
            e.printStackTrace();
            return Result.fail("error");
        }
    }

}
